home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SuperHack
/
SuperHack CD.bin
/
Hack
/
UTILS
/
SETSPASS.ZIP
/
SETSPASS.C
< prev
next >
Wrap
Text File
|
1992-10-23
|
4KB
|
128 lines
/* setspass.c - set the supervisor password from the NW386 console
Copyright (c) 1992 MurkWorks, All Rights Reserved
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear on all copies. MurkWorks makes no representations
about the suitability of this software for any purpose. It is
provided "as is" without express or implied warranty.
MurkWorks, P.O. Box 631, Potsdam, NY 13676 315-265-4717
-------------------------------------------------------------
Title: setspass
Purpose: Allow the Novell supervisor's password to be set
from the fileserver console. The user will be required
to enter the Novell server serial number, which is not
generally accesible to normal users.
If the entered serial number matches the server's
serial number, the user will be prompted to enter
a new supervisor password.
After the password is entered, the NLM will
broadcast an announcement to all users indicating that
the supervisor's password is being changed from the
console. It will then set the password.
*/
#include <stdio.h>
#include <nwbindry.h>
#include <nwserial.h>
#include <nwenvrn.h>
#include <nwcntask.h>
#include <string.h>
#include <conio.h>
int
main() /* don't need argc nor argv in this program */
{
char buff[80];
LONG serialNumber;
int rc;
WORD appNumber;
if(GetNetworkSerialNumber( & serialNumber, & appNumber)) {
perror("GetNetworkSerialNumber");
return(1);
}
/* if we couldn't get the serial number, print an error and
quit */
printf("This NLM will change the supervisor's password.\n");
printf("Before changing the password, you must enter this server's\n");
printf("serial number. This number can be found on the original diskettes\n\n");
while(1) {
LONG newSerialNumber;
printf("Enter the server serial number [<Enter> = Quit]:");
if(!fgets(buff,79, stdin) || buff[0] == '\n') {
SetAutoScreenDestructionMode(TRUE);
return(0);
/* quit if error or null line was
entered */
}
if(sscanf(buff,"%lx", & newSerialNumber) != 1 ||
newSerialNumber != serialNumber) {
printf("The number you entered was incorrect\n");
continue;
}
else
break;
}
while(1) {
printf("Enter the new supervisor password, it must be at least one character\n");
printf("and it will echo on the screen\n\n");
printf("New Supervisor Password:");
if(!fgets(buff,79,stdin) || buff[0] == '\n') {
printf("You may not set the password to a null value\n");
return(2);
/* quit in case the user entered null
just to get out */
}
clrscr(); /* clear the screen */
buff[strlen(buff) - 1] = 0; /* chop off trailing newline */
/* the password must be converted to upper case before being
stored in the bindery. This is because passwords are
case sensitive, but the NW shell always converts to
upper case before sending to the server.
*/
strupr(buff);
rc = ChangeBinderyObjectPassword("SUPERVISOR", OT_USER, "" , buff);
if(!rc)
break;
switch(rc) {
case 0xd7 :
printf("Duplicate password entered, enter a new password\n");
continue;
case 0xd8 :
printf("Password is not long enough, enter a new password\n");
continue;
default :
printf("Unable to change password, unknown error 0x%x\n",rc);
return(rc);
} /* end switch */
}
/* get here, password was changed ok */
/* send a broadcast to all users, no more than 58 characters though! */
SendConsoleBroadcast("The supervisor's password has been changed by setspass",
0, NULL);
printf("The supervisor password has been changed.\n");
return(0);
}